package itdfq.ydd.Behavior_Patters.Iterator;

/**
 * @Author GocChin
 * @Date 2021/5/15 14:28
 * @Blog: itdfq.com
 * @QQ: 909256107
 * @Descript:
 */
public class JutiPeople implements People{
    private Object object[] = {"爸爸","妈妈","哥哥","弟弟"};
    @Override
    public PeopleIterator createIterator() {
        return new SkyIterator();
    }
    class SkyIterator implements PeopleIterator{
        private int number=0;

        @Override
        public void setNumber(int i) {
            number=i;
        }

        @Override
        public void next() {
            if (number<object.length){
                number++;
            }
        }

        @Override
        public void previous() {
            if (number>0)
                number--;
        }

        @Override
        public boolean isLast() {
            return number==object.length;
        }

        @Override
        public boolean isFirst() {
            return number==0;
        }

        @Override
        public Object nowNumber() {
            return object[number];
        }
    }
}
